#include<stdio.h>
int arr1[1000];
int arr2[1000];
int my_best(int arr[1000], int size)
{
	int m = 0;
	int n = 0;
	int temp;
	for (m = 0; m < size-1 ; m++)
	{
		for (n = 0; n < size - m-1; n++)
		{
			if (arr[n] > arr[n + 1])
			{
				
				temp = arr[n];
				arr[n] = arr[n + 1];
				arr[n + 1] = temp;
			}
		}
	}
	int r = 0;
	for (r = 0; r < size; r++)
		printf("%d ", arr[r]);
}
int main()
{	
	int a = 0;
	int b = 0;
	scanf_s("%d %d", &a, &b);
	int i = 0;

	for (i = 0; i < a; i++)
	{
		scanf_s("%d", &arr1[i]);	
	}
	int j = 0;
	for (j = 0; j < b; j++)
	{
		scanf_s("%d", &arr2[j]);
	}
	int s = 0;
	int m = 0;
	int size = a + b;
	for (s = a; s < size; s++)
	{	
		arr1[s] = arr2[m];
		m++;
	}
	//for (int r = 0; r < size; r++)
		//printf("%d ", arr1[r]);
	//int size = sizeof(arr1) / (arr1[0]);
	my_best(arr1, size);
	return 0;
}